﻿using log4net;
using MySql.Data.MySqlClient;
using server;
using server.Business;
using server.DAO;
using server.Model;
using server.Tool;
using System;
using System.Collections.Generic;
using System.ServiceModel;
using System.ServiceModel.Activation;

namespace Restful
{
    //多线程

    [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall, ConcurrencyMode = ConcurrencyMode.Multiple, IncludeExceptionDetailInFaults = true)]
    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]

    public class ServiceknapsackImp : IknapsackService
    {

        private KnapsackDao knapsackDao = new KnapsackDao();
        public List<Knapsack_Info> GetKnapsackInfo(string grounpId)
        {
            return knapsackDao.GetKnapsackInfo(grounpId);
        }

        public string CheckGamePlayerTime(string grounpId)
        {
            Grounp p = MySqlExtendTools.GetEntityObjectByPrimaryKey<Grounp>(grounpId, "grounp");
            if (p.playerTime > 5)
            {
                return p.playerTime.ToString();
            }
            else
            {
                return "-1";
            }
        }

        public string SaveKnapsackInfo(string gameId, string knapsack_id, string startTime, string endTime, string count, string addCountValue)
        {
            return  knapsackDao.SaveKnapsackInfo( gameId,  knapsack_id,  startTime, endTime,  count, addCountValue);
        }

        public string DeleteKnapsack(string Id)
        {
            return knapsackDao.DeleteKnapsack(Id);
        }

        public string ModifyKnapsackInfo(string Id, string knapsack_id, string startTime, string endTime, string count,string gournpId,string addCountValue)
        {

            return knapsackDao.ModifyKnapsackInfo(Id, knapsack_id, startTime, endTime, count, gournpId, addCountValue);
        }

        public string GetKnapsackById(string Id)
        {

            return knapsackDao.GetKnapsackById(Id);
        }

        public List<Knapsack> GetKnapsackList()
        {
            //throw new NotImplementedException();
            return knapsackDao.GetKnapsackList();
        }

        public List<Knapsack_Detail> GetKnapsackDetailList(string game_id)
        {
           
            return knapsackDao.GetKnapsackDetailList(game_id);
        }

        public string SaveKnapsackDetail(List<Knapsack_Detail> list)
        {
            return  knapsackDao.SaveKnapsackDetail(list);
        }

        public string GetKnapsackInfoCount(string grounpId)
        {
          
            return knapsackDao.GetKnapsackInfoCount(grounpId);
        }

        //public void  LocateKnapsackDetailConfirm(UserKnapsack userKnapsack)
        //{
        //    knapsackDao.LocateKnapsackDetailConfirm(userKnapsack);
           
        //}

        public void StopEnergyTips(string userId)
        {
            knapsackDao.StopEnergyTips(userId);
        }
    }
}
